package br.com.edoc.fabrica;

import java.io.Serializable;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;


import br.com.edoc.gerentes.GerenteCadastro;
import br.com.edoc.gerentes.GerenteControleAcesso;
import br.com.edoc.gerentes.GerenteUploadIcones;

public class Atendente implements Serializable {
	
	private static Atendente _instancia =new Atendente();
	
	private AnnotationConfigApplicationContext contextoSpring;
	
	private Atendente(){
		
	}
	public synchronized GerenteUploadIcones chamaGerenteUploadIcones(){
		ApplicationContext context = getContextoSpring();
		if(context != null){
			return (GerenteUploadIcones) context.getBean("gerenteUploadIcones");	
		}else
			return null;
		
	}
	
	private AnnotationConfigApplicationContext getContextoSpring(){
		if(contextoSpring == null){
			contextoSpring =new AnnotationConfigApplicationContext(FabricaGerentes.class);
		}
		return contextoSpring;
	}

	public synchronized GerenteCadastro chamaGerenteCadastro(){
		ApplicationContext context = getContextoSpring();
		if(context != null){
			GerenteCadastro gc =(GerenteCadastro) context.getBean("gerenteCadastro");
			gc.setValidador(null);
			return  gc; 	
		}else
			return null;
	}
	
	private static final long serialVersionUID = 3177585591515318102L;

	public synchronized GerenteControleAcesso chamaGerenteControleAcesso(){
		ApplicationContext context = getContextoSpring();
		if(context != null){
			GerenteControleAcesso ga =(GerenteControleAcesso) context.getBean("gerenteControleAcesso");
			ga.setValidador(null);
			return ga;	
		}else
			return null;
		
	}
	
	public static synchronized Atendente getInstancia(){
		return _instancia;
	}
	
}